package model;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class House {
    private int id;
    private String houseName;
    private boolean available=true;

    public int getId() {
        return id;
    }

    public boolean isAvailable(Connection con, Book book) throws Exception {
        String sql="select th.available from t_house th join t_book tb on th.id=tb.bookHouseId ";
        PreparedStatement pstmt=con.prepareStatement(sql);
        ResultSet rs=pstmt.executeQuery();
        while (rs.next()){
            int a=rs.getInt("available");
            if(a==1){
                return true;
            }
        }
        return false;
    }

    public String getHouseName() {
        return houseName;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setAvailable(boolean available) {

        this.available = available;
    }

    public void setHouseName(String houseName) {
        this.houseName = houseName;
    }
}
